package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.order.ov.OrderConfirmRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class OrderController {
    @Autowired
    OrderFeignClient orderFeignClient;

    /**
     * 跳转到订单确认页；
     * @param model
     * @return
     */
    @GetMapping("/trade.html")
    public String trade(Model model){
        OrderConfirmRespVo confirmRespVo = orderFeignClient.orderConfirmData().getData();
        model.addAttribute("detailArrayList",confirmRespVo.getDetailArrayList());
        model.addAttribute("totalNum",confirmRespVo.getTotalNum());
        model.addAttribute("totalAmount",confirmRespVo.getTotalAmount());
        model.addAttribute("userAddressList",confirmRespVo.getUserAddressList());
        model.addAttribute("tradeNo",confirmRespVo.getTradeNo());
        return "order/trade";
    }
}
